package com.xunqi.blog.service.impl;

import com.xunqi.blog.dao.UserRepository;
import com.xunqi.blog.pojo.User;
import com.xunqi.blog.service.UserService;
import com.xunqi.blog.util.MD5Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserRepository userRepository;

    @Override
    public User checkUser(String userName, String password) {

        User user = userRepository.findByUsernameAndPassword(userName, MD5Utils.code(password));

        if (user != null) {
            return user;
        }
        return null;
    }
}
